import { request } from '@pkg/request/src';

export enum Api {
  page = '/vipcard/page',
  list = '/vipcard/list',
  get = '/vipcard/get',
  add = '/vipcard/save',
  update = '/vipcard/update',
  remove = '/vipcard/remove',
  setFirstRecommend = '/vipcard/setFirstRecommend',
  querySetServer = '/vipcard/querySetServer',
  setServer = '/vipcard/setServer',
  querySetAirport = '/vipcard/querySetAirport',
  setAirport = '/vipcard/setAirport',
  copyVipCard = '/vipcard/copyVipCard',
  copyVipCardSetAirport = '/vipcard/copyVipCardSetAirport',
}

enum vipcardCategoryApi {
  list = '/vipcardCategory/list',
}

enum categoryApi {
  list = '/category/list',
}

export const page = params =>
  request.get(
    {
      url: Api.page,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const vipcardList = params =>
  request.get(
    {
      url: Api.list,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const get = params =>
  request.get(
    {
      url: Api.get,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const add = params =>
  request.post(
    {
      url: Api.add,
      params: params,
    },
    { errorMessageMode: 'message' },
  );

export const update = params =>
  request.post(
    {
      url: Api.update,
      params: params,
    },
    { errorMessageMode: 'message' },
  );

export const remove = (ids: string) =>
  request.post(
    {
      url: Api.remove,
      params: { ids: ids },
    },
    { errorMessageMode: 'none' },
  );

export const vipcardCategoryList = params =>
  request.get(
    {
      url: vipcardCategoryApi.list,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const categoryList = params =>
  request.get(
    {
      url: categoryApi.list,
      params: params,
    },
    { errorMessageMode: 'none', successMessageMode: 'none' },
  );

export const setFirstRecommend = (vipcardId, firstRecommend) =>
  request.post(
    {
      url: Api.setFirstRecommend,
      params: { vipcardId: vipcardId, firstRecommend: firstRecommend },
    },
    { errorMessageMode: 'none' },
  );

export const querySetServer = params =>
  request.get(
    {
      url: Api.querySetServer,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const setServer = params =>
  request.post(
    {
      url: Api.setServer,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const querySetAirport = params =>
  request.get(
    {
      url: Api.querySetAirport,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const setAirport = params =>
  request.post(
    {
      url: Api.setAirport,
      params: params,
    },
    { errorMessageMode: 'none' },
  );

export const copyVipCard = params =>
  request.post(
    {
      url: Api.copyVipCard,
      params: params,
    },
    { errorMessageMode: 'message' },
  );

export const copyVipCardSetAirport = params =>
  request.post(
    {
      url: Api.copyVipCardSetAirport,
      params: params,
    },
    { errorMessageMode: 'message' },
  );
